//模板引擎
let name = 'zf';
let age = 10;
let str = "${name}今年${age}岁了";
//.+匹配任意字符1到多个，加? 非贪婪模式，尽可能少找，eval将找到的字符串转成变量
str = str.replace(/\$\{(.+?)\}/g,function(){
    return eval(arguments[1])
})
console.log(str);

// npm install ejs
// <%=name%><%=age%>
let ejs = require('ejs');
let fs = require('fs');
let path = require('path');
let str1 = fs.readFileSync(path.resolve(__dirname,'index.html'),'utf8');
let newStr = ejs.render(str,{
    name:'zf',
    age:10
});
console.log(newStr)
